<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>超市订单管理系统</title>
    <link type="text/css" rel="stylesheet" href="../../static/css/style.css" th:href="@{/css/style.css}"/>
    <link type="text/css" rel="stylesheet" href="../../static/css/public.css" th:href="@{/css/public.css}"/>
    <link type="text/css" rel="stylesheet" href="../../static/css/pagination.css" th:href="@{/css/pagination.css}"/>
</head>
<body>

<!--头部-->
<div th:replace="commons/common::header"></div>
<!--时间-->
<div th:replace="commons/common::time"></div>
<!--主体内容-->
<section class="publicMian ">
    <!--left-->
    <div th:replace="commons/common::left"></div>
    <div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>订单管理页面 >> 订单添加页面</span>
        </div>
        <div class="providerAdd">
            <form id="billForm" name="billForm">
                <!--div的class 为error是验证错误，ok是验证成功-->
                <div>
                    <input type="hidden" th:value="${bill.id}" id="id"/>
                    <label for="billCode">订单编码：</label>
                    <input type="text" name="billCode" id="billCode" th:value="${bill.billCode }" readonly="readonly">
                </div>
                <div>
                    <label for="productName">商品名称：</label>
                    <input type="text" name="productName" id="productName" th:value="${bill.productName }">
                    <font color="red"></font>
                </div>
                <div>
                    <label for="productUnit">商品单位：</label>
                    <input type="text" name="productUnit" id="productUnit" th:value="${bill.productUnit }">
                    <font color="red"></font>
                </div>
                <div>
                    <label for="productCount">商品数量：</label>
                    <input type="text" name="productCount" id="productCount" th:value="${bill.productCount }">
                    <font color="red"></font>
                </div>
                <div>
                    <label for="totalPrice">总金额：</label>
                    <input type="text" name="totalPrice" id="totalPrice" th:value="${bill.totalPrice }">
                    <font color="red"></font>
                </div>
                <div>
                    <label for="providerId">供应商：</label>
                    <input type="hidden" th:value="${bill.providerId }" id="pid" />
                    <select name="providerId" id="providerId">
                        <option value="">请选择</option>
                        <option th:each="provider:${providerlist}" th:value="${provider.id}" th:text="${provider.proName}" th:selected="${provider.id==bill.providerId}"></option>
                    </select>
                    <font color="red"></font>
                </div>
                <div>
                    <label >是否付款：</label>
                    <!--<c:if test="${bill.isPayment == 1 }">
                        <input type="radio" name="isPayment" value="1" checked="checked">未付款
                        <input type="radio" name="isPayment" value="2" >已付款
                    </c:if>
                    <c:if test="${bill.isPayment == 2 }">
                        <input type="radio" name="isPayment" value="1">未付款
                        <input type="radio" name="isPayment" value="2" checked="checked">已付款
                    </c:if>-->

                    <input type="radio" name="isPayment" value="1" th:checked="${bill.isPayment==1}">未付款
                    <input type="radio" name="isPayment" value="2" th:checked="${bill.isPayment==2}">已付款
                </div>
                <div class="providerAddBtn">
                    <input type="button" name="save" id="saveBtn" value="保存">
                    <input type="button" id="back" name="back" value="返回" >
                </div>
            </form>
        </div>

    </div>
</section>


<div th:replace="commons/common::footer"></div>
<script type="text/javascript" src="../../static/js/time.js" th:src="@{/js/time.js}"></script>
<script type="text/javascript" src="../../static/js/jquery-1.8.3.min.js" th:src="@{/js/jquery-1.8.3.min.js}"></script>
<script type="text/javascript" src="../../static/js/common.js" th:src="@{/js/common.js}"></script>
<script type="text/javascript" src="../../static/calendar/WdatePicker.js" th:src="@{/calendar/WdatePicker.js}"></script>
<script type="text/javascript" src="../../static/js/rollpage.js" th:src="@{/js/rollpage.js}"></script>
<script type="text/javascript" src="../../static/js/jquery.pagination.js" th:src="@{/js/jquery.pagination.js}"></script>
<script type="text/javascript" src="../../static/js/jquery.form.js" th:src="@{/js/jquery.form.js}"></script>
<script>
    $("#saveBtn").click(function () {
        const id=$("#id").val();
        const billCode=$("#billCode").val();
        const productName=$("#productName").val();
        const productUnit=$("#productUnit").val();
        const productCount=$("#productCount").val();
        const totalPrice=$("#totalPrice").val();
        const providerId=$("#providerId").val();
        const isPayment=$("input[name='isPayment']:checked").val();
        alert(isPayment);
        const jsonObj={
            billCode:billCode,
            productName:productName,
            productUnit:productUnit,
            productCount:productCount,
            totalPrice:totalPrice,
            providerId:providerId,
            isPayment:isPayment,
            id:id
        }
        $.ajax({
            url:"[[@{/bill/doModify}]]",
            type:"post",
            data:jsonObj,
            beforeSend:function () {
                return true;
            },
            success:function (result) {
                if (result.success){
                    window.location.href="[[@{/bill/list}]]";
                }
            }

        })

    })
</script>

</body>
</html>